package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.activity.ActivityDisperseGoldInfo;
import com.yanqu.road.pb.activity.ActivityDisperseGoldProto;
import com.yanqu.road.utils.string.StringUtils;

public class ActivityDisperseGoldPb {

    public static ActivityDisperseGoldInfo parseToDisperseGoldInfo(ActivityDisperseGoldProto.ActivityDisperseGoldInfoTemp msg) {
        ActivityDisperseGoldInfo info = new ActivityDisperseGoldInfo();
        info.setActivityId(msg.getActivityId());
        info.setType(msg.getType());
        info.setUserId(msg.getUserId());
        info.setManifesto(msg.getManifesto());
        info.setHonoraryTitles(StringUtils.listToString(msg.getDecorationIdListList(),","));
        info.setUserBaseInfo(PlayerBasePb.parseToUserBaseInfo(msg.getPlayerInfo()));
        info.setServerList(StringUtils.stringToLongList(msg.getServerList(), ","));
        info.setBeginTime(msg.getBeginTime());
        //以下可能为空
        info.setDisperseId(msg.getDisperseId());
        info.setServerId(msg.getServerId());
        info.setReward(msg.getReward());
        info.setPlayerNum(msg.getPlayerNum());
        info.setGroupId(msg.getGroupId());
        return info;
    }

    public static ActivityDisperseGoldProto.ActivityDisperseGoldInfoTemp.Builder parseToDisperseGoldInfoTemp(ActivityDisperseGoldInfo goldInfo) {
        ActivityDisperseGoldProto.ActivityDisperseGoldInfoTemp.Builder tempBuilder = ActivityDisperseGoldProto.ActivityDisperseGoldInfoTemp.newBuilder();
        tempBuilder.setActivityId(goldInfo.getActivityId());
        tempBuilder.setType(goldInfo.getType());
        tempBuilder.setUserId(goldInfo.getUserId());
        tempBuilder.setManifesto(goldInfo.getManifesto());
        tempBuilder.addAllDecorationIdList(StringUtils.stringToIntegerList(goldInfo.getHonoraryTitles(),","));
        tempBuilder.setServerList(StringUtils.listToString(goldInfo.getServerList(),","));
        tempBuilder.setPlayerInfo(PlayerBasePb.parsePlayerBaseTempMsg(goldInfo.getUserBaseInfo()));
        tempBuilder.setBeginTime(goldInfo.getBeginTime());

        tempBuilder.setDisperseId(goldInfo.getDisperseId());
        tempBuilder.setServerId(goldInfo.getServerId());
        if(!StringUtils.isNullOrEmpty(goldInfo.getReward())) {
            tempBuilder.setReward(goldInfo.getReward());
        }
        tempBuilder.setPlayerNum(goldInfo.getPlayerNum());
        tempBuilder.setGroupId(goldInfo.getGroupId());
        return tempBuilder;
    }
}
